<template>
	<scroll-view :scroll-top="scrollTop" scroll-y="true" class="scroll-Y" @scroll="scroll"
		@scrolltoupper="scrolltoupper" :scroll-with-animation="true">
		<view class="container">
			<view class="item" v-for="(item,index) in wfList" @click="itemTap(item)" :key="index">
				<image :src="item.iconImg" mode="widthFix" class="item-img" />
				<view class="item-info">
					<view class="info-nickname textShadow">{{ item.title }}</view>
					<view class="info-nickname name">{{ item.name }}</view>
				</view>
			</view>
		</view>
		<!-- 没有结果添加空状态显示 -->
		<u-empty v-if="!wfList[0]" mode="search" icon="http://cdn.uviewui.com/uview/empty/car.png">
		</u-empty>
	</scroll-view>
</template>

<script>
	export default {
		props: {
			// 瀑布流列表
			wfList: {
				type: Array,
				require: true
			}
		},
		data() {
			return {
				scrollTop: 0,
				old: {
					scrollTop: 0
				}
			};
		},
		onLoad() {
			// this.leftList = this.wfList

		},
		watch: {
			// 监听列表数据变化
			wfList() {}
		},
		methods: {
			scroll(e) {
				// console.log(e)
				this.old.scrollTop = e.detail.scrollTop
			},
			scrolltoupper(e) {
				// console.log(e);
			},
			// item点击
			itemTap(item) {
				this.$emit('itemTap', item)
			},

			// 刷新
			refresh() {},
			goTop() {
				this.scrollTop = this.old.scrollTop
				this.$nextTick(function() {
					this.scrollTop = 0
				});
			}
		}
	}
</script>

<style lang="scss" scoped>
	$page-padding: 10px;
	$grid-gap: 10px;

	.container {
		width: 100%;
		display: flex;
		flex-wrap: wrap;
		flex-direction: row;
		margin-top: 10rpx;

		&::after {
			flex: auto;
			content: "";
		}

		.item {
			margin-bottom: 10rpx;
			margin: 0 calc(5.5% / 6);
			margin-bottom: 15rpx;
			width: 31.5%;
			height: 300rpx;
			text-align: center;
			border-radius: 15rpx;
			background: #fff;
			overflow: hidden;

			.item-img {
				width: 100%;
			}

			.info-nickname {
				font-size: 12px;
				color: #333;
			}

			.name {
				background-clip: text;
				/*设置元素的背景（背景图片或颜色）延伸范围 */
				color: transparent;
				background-image: linear-gradient(to right, red, blue);
			}

			.textShadow {
				text-shadow: 5rpx 5rpx 10rpx #999;
			}
		}
	}

	.scroll-Y {
		height: calc(100vh - 690rpx);
	}
</style>
